<css href="__PUBLIC__/boot-date/css/bootstrap-datetimepicker.min.css" />
<script src="__PUBLIC__/boot-date/js/bootstrap-datetimepicker.min.js"></script>
<script src="__PUBLIC__/boot-date/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<div class="table-tools">
    <!--<a href="__URL__/addUI" class="btn btn-info" title="添加权限"><i class="fa fa-copy"></i> 添 加 </a>-->
    <!--<button type="submit" class="btn btn-primary" title="删除勾选的资源"><i class="glyphicon glyphicon-remove"></i> 删 除 </button>-->
    <!--<button type="button" class="btn btn-success" title="重新排序资源" onclick="sortQuestions()"><i class="fa fa-copy"></i> 重 排 </button>-->
    <form class="form-inline" method="post" action="__URL__/orderList" id="search_form"  role="form">
        <input type="hidden" name="pagenum" id="pagenum_hidden" value="{$page.pagenum}">
        <input type="hidden" name="count" value="{$recordcount}">
        <div class="form-group">
            <input type="text" name="user_id" value="{$user_id}" placeholder="请输入用户id">
            <input type="text" name="goods_id" value="{$goods_id}" placeholder="请输入充值卡id">
            <select  name="status" id="status" class="form-control">
                <switch name="status">
                    <case value="-1">
                        <option value="-1" selected>状态</option>
                        <!--<option value="2">审核失败</option>-->
                        <option value="1">审核成功</option>
                        <option value="0">等待审核</option>
                    </case>
                    <case value="0">
                        <option value="-1">状态</option>
                        <!--<option value="2">等待审核</option>-->
                        <option value="1">审核成功</option>
                        <option value="0" selected>等待审核</option>
                    </case>
                    <case value="1">
                        <option value="-1">状态</option>
                        <!--<option value="2">审核失败</option>-->
                        <option value="1" selected>审核成功</option>
                        <option value="0">等待审核</option>
                    </case>
                    <!--<case value="2">-->
                        <!--<option value="-1">状态</option>-->
                        <!--<option value="2" selected>审核失败</option>-->
                        <!--<option value="1">审核成功</option>-->
                        <!--<option value="0">等待审核</option>-->
                    <!--</case>-->
                    <default/>
                    <option value="-1" selected>状态</option>
                    <!--<option value="2">审核失败</option>-->
                    <option value="1">审核成功</option>
                    <option value="0">等待审核</option>
                </switch>
            </select>
        </div>
        <div class="form-group" style="margin-left: 1%">
            <label class="col-md-6 col-xs-12 control-label" > 开始时间</label>
            <div class="col-md-2">
                <input size="16" type="text" id="startTime" name="startTime" value="{$startTime}" readonly class="start_datetime">
            </div>
        </div>
        <div class="form-group" style="margin-left: 1%">
            <label class="col-md-6 col-xs-12 control-label" >结束时间</label>
            <div class="col-md-2">
                <input size="16" type="text" id="endTime" name="endTime" value="{$endTime}" readonly class="end_datetime">
            </div>
        </div>
        <button style="margin-left: 2%"  type="button" onclick="gotoPage(0)">搜索</button>
    </form>
    <p>充值卡领取记录</p>
</div>

<table id="users-table" class="table table-striped table-hover table-condensed datatable">
    <thead>
    <tr id="log_{$log.id}">
        <th width="50px">ID</th>
        <th>充值卡标题</th>
        <th>充值卡ID</th>
        <th>用户ID</th>
        <th>微信号</th>
        <th>商品价格(人民币)</th>
        <th>手续费(钻石)</th>
        <th>总需钻石</th>
        <th>状态</th>
        <th>创建时间</th>
        <th>操作</th>
        <!--<th width="150px">操作</th>-->
        <!--<th width="80px">排序</th>-->
    </tr>
    </thead>
    <tbody>
    <volist name="list" id="log">
        <tr>
            <!--<td width="50px"><input name='id[]' type="checkbox" value="{$log.id}" /></td>-->
            <td class="question-name">{$log.id}</td>
            <td class="question-name">{$log.title}</td>
            <td class="question-name">{$log.goods_id}</td>
            <td class="question-name">{$log.user_id}</td>
            <td class="question-name">{$log.wechat_number}</td>
            <td class="question-name">{$log.money}</td>
            <td class="question-name">{$log.poundage}</td>
            <td class="question-name">{$log.total_money}</td>
            <td class="question-name" id="verify_{$log.id}">
                <switch name="log.status">
                    <case value="0">
                        等待审核
                    </case>
                    <case value="1">
                        审核成功
                    </case>
                    <!--<case value="2">-->
                        <!--审核失败-->
                    <!--</case>-->
                </switch>
            </td>
            <td class="question-name">{$log.create_time}</td>
            <td>
                <a onclick="showInfo('{$log.user_id}')" data-id="{$log.id}"
                   class="btn btn-default btn-rounded btn-condensed btn-sm" title="查看用户信息"><span class="fa fa-pencil">信息</span>
                </a>
                <eq name="log.status" value="0">
                    <div id="verify_div_{$log.id}">
                        <a onclick="verify(this,1)" data-id="{$log.id}"
                           class="btn btn-default btn-rounded btn-condensed btn-sm" title="通过审核"><span class="fa fa-pencil">通过</span>
                        </a>
                    </div>
                </eq>

                <!--<a onclick="deleteById('{$user.id}')" class="btn btn-default btn-rounded btn-condensed btn-sm" title="删除权限"><span class="glyphicon glyphicon-remove">删除</span></a>-->
            </td>
            <!--<td width="80px"><input name="sort[{$user.id}]" class="sort-input" type="text" value="{$user.sort}" /></td>-->
        </tr>

    </volist>
    <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td>总价格:{$countMoney.total_money}</td>
        <td>总手续费:{$countMoney.total_poundage}</td>
        <td>总钻石:{$countMoney.total_integral}</td>
        <td></td>
    </tr>
    </tbody>
</table>
<nav style="float:right">
    <spen class="total">共 {$recordcount}条记录</spen>
    <div class="fr">
        <ul class="pagination">
            <eq name="page['pagenum']" value="1">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('1')">«</a></li>
            <foreach name="page.pagenums" item="vo">
                <eq name="page['pagenum']" value="$vo">
                    <li class="active"><a href="#">{$vo}</a></li>
                    <else/>
                    <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                </eq>
            </foreach>
            <eq name="page['pagenum']" value="$page.endPage">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
        </ul>
    </div>
</nav>
<div class="modal fade" id="hint_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" >提示</h4>
            </div>
            <div class="modal-body" id="hint_content">
            </div>
            <div class="modal-footer">
                <button type="button"  class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="verify_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="verify_title">提示</h4>
            </div>
            <div class="modal-body" id="verify_content">
                您确定要通过审核该记录吗？
            </div>
            <input type="hidden" name="log_id" id="log_id">
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" id="verify_confirm" onclick="verifyConfirm()" class="btn btn-primary">确定</button>
            </div>
        </div>
    </div>
</div>

<div class="modal fade" id="userInfo_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title">用户信息</h4>
            </div>
            <div class="modal-body">
                <table class="table table-striped table-hover table-condensed datatable">
                    <thead>
                    <tr>
                        <th width="50px">ID</th>
                        <th>昵称</th>
                        <th>手机号</th>
                        <th>微信号</th>
                        <th>钻石</th>
                        <th>金币</th>
                        <th>游戏名称</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr id="user_info_tr">
                        </tr>
                    </tbody>
                </table>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/assets/js/layer.js"></script>
<script>
    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('#search_form').submit();
    }
    $(".start_datetime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
    }).on('change',function(ev){
        var startDate = $('.start_datetime').val();
        console.info('startDate:'+startDate);
        $(".end_datetime").datetimepicker('setStartDate',startDate);
        $(".start_datetime").datetimepicker('hide');
    });
    $(".end_datetime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: "month", //选择日期后，不会再跳转去选择时分秒
        language:  'zh-CN',
    }).on('change',function(ev){
        var returnDate = $(".end_datetime").val();
        console.info('returnDate:'+returnDate);
        $(".start_datetime").datetimepicker('setReturnDate',returnDate);
        $(".end_datetime").datetimepicker('hide');
    });

    function verify(obj,verify_type){
        $('#log_id').val($(obj).data('id'));
        $('#verify_modal').modal();
    }
    function modalInfo(info,success){
//        layer.msg(info);
        if(success) {
            layer.msg(info, {icon: 1});
        }else{
            layer.msg(info, {icon: 2});
        }

    }

    function showInfo(user_id){
        $.ajax({
            type: "POST",
            url: "__APP__/Admin/User/showUserInfo",
            data: {user_id:user_id},
            dataType: "json",
            success: function (data) {
                if(data.success){
                    var html = '';
                    var user = data.userInfo;
                    html +='<td class="question-name">'+user.id+'</td>';
                    html +='<td class="question-name">'+user.nickname+'</td>';
                    html +='<td class="question-name">'+user.phone+'</td>';
                    html +='<td class="question-name">'+user.wechat_number+'</td>';
                    html +='<td class="question-name">'+user.integral+'</td>';
                    html +='<td class="question-name">'+user.gold+'</td>';
                    html +='<td class="question-name">'+user.game_name+'</td>';
                    $('#user_info_tr').empty().append(html);
                    $('#userInfo_modal').modal();
                }
            },
            error: function (data) {
                $("#hint_content").empty().append("请求超时！");
                $("#hint_modal").modal();
            }
        });
    }

    function verifyConfirm(){
        $('#verify_modal').modal('hide');
        var log_id = $('#log_id').val();
        if(log_id == ''){
            return;
        }
        $.ajax({
            type: "POST",
            url: "__URL__/verifyOrder",
            data: {log_id:log_id},
            dataType: "json",
            success: function (data) {
                $("#hint_content").empty().append(data.message);
                $("#hint_modal").modal();
                if(data.success){
                    $('#verify_div_'+log_id).hide();
                    $('#verify_'+log_id).empty().append('通过审核');
                }
            },
            error: function (data) {
                $("#hint_content").empty().append("请求超时！");
                $("#hint_modal").modal();
            }
        });
    }
</script>